﻿// ============================================================================
//  _ __   ___  ___  ___ _ __ ___  _   _
// | '_ \ / _ \/ __|/ _ \ '_ ` _ \| | | |
// | | | |  __/\__ \  __/ | | | | | |_| |
// |_| |_|\___||___/\___|_| |_| |_|\__,_|
//
// NES Emulator by daxnet, 2024
// MIT License
// ============================================================================

using Color = Microsoft.Xna.Framework.Color;

namespace NesEmu.Console.Palettes;

internal abstract class ColorPalette
{
    #region Private Fields

    // ReSharper disable once InconsistentNaming
    private static readonly Dictionary<string, ColorPalette> _palettes = new()
    {
        { "Default", new DefaultPalette() },
        { "Default Grayscale", new DefaultGrayscale() },
        { "2C02_aps_ela_default", new _2C02_aps_ela_default() },
        { "2C02-2C07_aps_ela_persune_neutral", new _2C02_2C07_aps_ela_persune_neutral() },
        { "2C02G_aps_ela_NTSC_persune_GVUSB2_NTSC_M", new _2C02G_aps_ela_NTSC_persune_GVUSB2_NTSC_M() },
        { "2C02G_aps_ela_NTSC_persune_GVUSB2_NTSC_M_J", new _2C02G_aps_ela_NTSC_persune_GVUSB2_NTSC_M_J() },
        { "2C02G_aps_ela_NTSC_persune_tink", new _2C02G_aps_ela_NTSC_persune_tink() },
        { "2C02G_phs_aps_ela_NTSC", new _2C02G_phs_aps_ela_NTSC() },
        { "2C02G_phs_aps_ela_NTSC_1953", new _2C02G_phs_aps_ela_NTSC_1953() },
        { "2C02G_phs_aps_ela_NTSC-J", new _2C02G_phs_aps_ela_NTSC_J() },
        { "2C03_DeMarsh_1980s_RGB", new _2C03_DeMarsh_1980s_RGB() },
        { "2C05-99_composite_forple", new _2C05_99_composite_forple() },
        { "2C07_ela_PAL", new _2C07_ela_PAL() },
    };

    #endregion Private Fields

    #region Protected Methods

    protected abstract Color[] GetPaletteColors();

    #endregion Protected Methods

    #region Public Properties

    public Color[] Colors => GetPaletteColors();

    public static IEnumerable<KeyValuePair<string, ColorPalette>> Palettes => _palettes;

    public static ColorPalette GetColorPaletteByName(string name) => _palettes[name];

    #endregion Public Properties
}